package itheima.jdk8.stream2;


import java.text.Collator;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Locale;

public class MyComparatorTest {


    //定义排序函数
    public static String[] getSortOfChinese(String[] a) {
        // Collator 类是用来执行区分语言环境这里使用CHINA
        Comparator cmp = Collator.getInstance(Locale.CHINA);
        // JDKz自带对数组进行排序。
        Arrays.sort(a, cmp);
        return a;
    }


    public static void main(String[] args) {
        List<String> list = Arrays.asList("nihao", "hello", "world", "welcome","euphy","Yophy");
//        List<String> list = Arrays.asList("占三", "王武", "里斯", "哈哈","啊大","贝贝");
//
//
//        String[] strs1=list.toArray(new String[list.size()]);
//        MyComparatorTest.getSortOfChinese(strs1);
//        for(String s:strs1){
//            System.out.println(s);
//        }
//        System.out.println("汉子排序："+strs1);
//        System.out.println(list.stream().sorted((o1, o2) -> o1.compareToIgnoreCase(o2)).collect(Collectors.toList()));
        //list.sort((o1, o2) -> o1.compareToIgnoreCase(o2));
//
       // Collections.sort(list, (item1, item2) -> item1.length() - item2.length());
//        Collections.sort(list,(x,y)->x.compareToIgnoreCase(y));
//        System.out.println(list);
//        Collections.sort(list,Comparator.comparingInt((String i)->i.length()).reversed().thenComparing((x,y)->x.compareToIgnoreCase(y)));
//        Collections.sort(list, (item1, item2) -> item2.length() - item1.length());

//        Collections.sort(list, Comparator.comparingInt(String::length).reversed());

//        Collections.sort(list, Comparator.comparingInt((String item) -> item.length()).reversed());
//        Collections.sort(list, Comparator.comparingInt((String item) -> item.length()).reversed());

//        list.sort(Comparator.comparingInt(String::length).reversed());
//        list.sort(Comparator.comparingInt((String item) -> item.length()).reversed());

//        Collections.sort(list, Comparator.comparingInt(String::length).thenComparing(String.CASE_INSENSITIVE_ORDER));

//        Collections.sort(list, Comparator.comparingInt(String::length).
//                thenComparing((item1, item2) -> item1.toLowerCase().compareTo(item2.toLowerCase())));

//        Collections.sort(list, Comparator.comparingInt(String::length).
//                thenComparing(Comparator.comparing(String::toLowerCase)));

//        Collections.sort(list, Comparator.comparingInt(String::length).
//                thenComparing(Comparator.comparing(String::toLowerCase, Comparator.reverseOrder())));

//        Collections.sort(list, Comparator.comparingInt(String::length).reversed().
//                thenComparing(Comparator.comparing(String::toLowerCase, Comparator.reverseOrder())));

        Collections.sort(list, Comparator.comparingInt(String::length).reversed()
                .thenComparing(Comparator.comparing(String::toLowerCase, Comparator.reverseOrder()))
                .thenComparing(Comparator.reverseOrder())
                );

        System.out.println(list);
    }
}
